<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.prime.com.tr/ui" template="../template.xhtml">

	<ui:define name="head"></ui:define>
	<ui:define name="right">

		<div class="section">
			<div class="section-title">#{msgs.mensagens}</div>
			<div class="section-content">
				<p:growl id="messages" showDetail="false" />
			</div>
		</div>
	</ui:define>
	<ui:define name="content">
		<div class="section">
			<div class="section-title">#{msgs.unidade_gestora}</div>

			<div class="section-content">

				<h:form id="ac">
					<h:outputLabel styleClass="bold" value="#{msgs.selecionar_unidade_gestora}" />

					<h:panelGrid columns="2">

						<h:outputLabel for="ua"
							value="#{msgs.form_unidade_adiministrativa}:" />
						<p:selectOneMenu id="ua" value="#{solicitacaoMB.view.ua}" var="ua"
							converter="uaConverter" required="true" styleClass="grande">
							<f:selectItem itemLabel="#{msgs.form_selecione}" itemValue="" />
							<f:selectItems value="#{solicitacaoMB.view.uas}" itemValue="#{u}"
								itemLabel="#{u.nome}" var="u" />
							<p:column>#{ua.nome}</p:column>
							<p:ajax update="ug" listener="#{solicitacaoMB.filtrarUG}" />
						</p:selectOneMenu>

						<h:outputLabel  for="ug" value="#{msgs.form_unidade_gestora}:" />
						<p:selectOneMenu id="ug"
							value="#{solicitacaoMB.view.pessoaOriginal}" var="ug"
							converter="ugConverter" required="true"  styleClass="grande">
							<f:selectItem itemLabel="#{msgs.form_selecione}" itemValue="" />
							<f:selectItems value="#{solicitacaoMB.view.ugs}" itemValue="#{u}"
								itemLabel="#{u.nome}" var="u" />
							<p:column>#{ug.nome}</p:column>
						</p:selectOneMenu>

					</h:panelGrid>

					<p:commandButton value="Selecionar"
						update="pessoaForm respForm messages"
						actionListener="#{solicitacaoMB.selecionarPessoa}" />

				</h:form>

				<div class="content-separator"></div>
				<h:form id="pessoaForm" prependId="false">

					<p:panel id="panel1" header="#{msgs.dados_unidade_gestora}"
						style="margin-bottom:10px;">
						<p:messages />
						<h:panelGrid columns="3">

							<h:outputLabel styleClass="bold" for="nome" value="#{msgs.form_nome}: *" />
							<p:inputText id="nome"
								value="#{solicitacaoMB.view.pessoaAlterada.nome}"
								required="true" label="nome">
								<f:validateLength minimum="3" />
							</p:inputText>
							<p:message for="nome" />

							<h:outputLabel styleClass="bold" for="sigla" value="#{msgs.form_sigla }: *" />
							<p:inputText id="sigla"
								value="#{solicitacaoMB.view.pessoaAlterada.sigla}"
								required="true" label="sigla">
								<f:validateLength minimum="3" />
							</p:inputText>
							<p:message for="sigla" />

							<h:outputLabel styleClass="bold" for="cnpj" value="#{msgs.form_cnpj}: *" />
							<p:inputText id="cnpj"
								value="#{solicitacaoMB.view.pessoaAlterada.cnpj}"
								required="true" label="cnpj" />
							<p:message for="cnpj" />

							<h:outputLabel styleClass="bold" for="insEstadual"
								value="#{msgs.form_inscricao_estadual}: " />
							<p:inputText id="insEstadual"
								value="#{solicitacaoMB.view.pessoaAlterada.insEstadual}"
								required="false" label="insEstadual">
								<f:validateLength minimum="3" />
							</p:inputText>
							<p:message for="insEstadual" />

							<h:outputLabel styleClass="bold" for="dataCriacao"
								value="#{msgs.form_data_criacao}: *" />
							<p:calendar id="dataCriacao"
								value="#{solicitacaoMB.view.pessoaAlterada.dataCriacao}"
								showOn="button" pattern="dd/MM/yyyy" />
							<p:message for="dataCriacao" />


							<h:outputLabel styleClass="bold" for="unidadeAdministrativa"
								value="#{msgs.form_unidade_adiministrativa}: *" />
							<p:selectOneMenu id="unidadeAdministrativa"
								value="#{solicitacaoMB.view.ua}" var="unidadeAdministrativa"
								converter="uaConverter" required="true">
								<f:selectItem itemLabel="#{msgs.form_selecione}" itemValue="" />
								<f:selectItems value="#{solicitacaoMB.view.uas}"
									itemValue="#{u}" itemLabel="#{u.nome}" var="u" />
								<p:column>#{unidadeAdministrativa.nome}</p:column>
							</p:selectOneMenu>
							<p:message for="unidadeAdministrativa" />

							<h:outputLabel styleClass="bold" for="tipoUg" value="#{msgs.form_tipo}: *" />
							<p:selectOneMenu id="tipoUg"
								value="#{solicitacaoMB.view.pessoaAlterada.tipoUg}" var="tipoUg"
								converter="tcConverter" required="true">
								<f:selectItem itemLabel="Selecione ..." itemValue="" />
								<f:selectItems value="#{solicitacaoMB.view.tipoUgs}"
									itemValue="#{tug}" itemLabel="#{tug.descricao}" var="tug" />
								<p:column>#{tipoUg.descricao}</p:column>
							</p:selectOneMenu>
							<p:message for="tipoUg" />

							<h:outputLabel styleClass="bold" for="tel" value="#{msgs.form_telefone}: *" />
							<p:inputText id="tel"
								value="#{solicitacaoMB.view.telefone.numero}" required="true"
								label="tel" />
							<p:message for="tel" />

							<h:outputLabel styleClass="bold" for="email" value="#{msgs.form_email}: *" />
							<p:inputText id="email"
								value="#{solicitacaoMB.view.email.descricao}" required="true"
								label="email" />
							<p:message for="email" />

						</h:panelGrid>
					</p:panel>
					<p:panel id="panel2" header="#{msgs.endereco_residencial}"
						style="margin-bottom:10px;">
						<h:panelGrid columns="3">
							<h:outputLabel styleClass="bold" for="logradouro"
								value="#{msgs.form_logradouro}: *" />
							<p:inputText id="logradouro"
								value="#{solicitacaoMB.view.endereco.logradouro}"
								required="true" label="logradouro" />
							<p:message for="logradouro" />
							<h:outputLabel styleClass="bold" for="numero" value="#{msgs.form_numero}: *" />
							<p:inputText id="numero"
								value="#{solicitacaoMB.view.endereco.numero}" required="true"
								label="numero" />
							<p:message for="numero" />
							<h:outputLabel styleClass="bold" for="complemento"
								value="#{msgs.form_complemento}:" />
							<p:inputText id="complemento"
								value="#{solicitacaoMB.view.endereco.complemento}"
								label="complemento" required="false" />
							<p:message for="complemento" />
							<h:outputLabel styleClass="bold" for="bairro" value="#{msgs.form_bairro}: *" />
							<p:inputText id="bairro"
								value="#{solicitacaoMB.view.endereco.bairro}" required="true"
								label="bairro" />
							<p:message for="bairro" />
							<h:outputLabel styleClass="bold" for="cep" value="#{msgs.form_cep}: *" />
							<p:inputText id="cep" value="#{solicitacaoMB.view.endereco.cep}"
								required="true" label="cep" />
							<p:message for="cep" />
							<h:outputLabel styleClass="bold" for="uf" value="#{msgs.form_estado}:*" />
							<p:selectOneMenu id="uf"
								value="#{solicitacaoMB.view.endereco.uf}" var="uf"
								converter="ufConverter" required="true">
								<f:selectItem itemLabel="#{msgs.form_selecione}" itemValue="" />
								<f:selectItems value="#{solicitacaoMB.view.ufs}"
									itemValue="#{u}" itemLabel="#{u.descricao}" var="u" />
								<p:column>#{uf.descricao}</p:column>
								<p:ajax update="municipio"
									listener="#{solicitacaoMB.filtrarMunicipio}" />
							</p:selectOneMenu>
							<p:message for="uf" />
							<h:outputLabel styleClass="bold" for="municipio"
								value="#{msgs.form_municipio}: *" />
							<p:selectOneMenu id="municipio"
								value="#{solicitacaoMB.view.endereco.municipio}"
								converter="municipioConverter" var="municipio" required="true">
								<f:selectItem itemLabel="#{msgs.form_selecione}" itemValue="" />
								<f:selectItems value="#{solicitacaoMB.view.municipios}"
									itemValue="#{m}" itemLabel="#{m.descricao}" var="m" />
								<p:column>#{municipio.descricao}</p:column>
							</p:selectOneMenu>
							<p:message for="municipio" />
						</h:panelGrid>
					</p:panel>

					<p:panel id="panel3" header="#{msgs.responsabilidades}:"
						style="margin-bottom:10px;">


						<p:dataTable
							value="#{solicitacaoMB.view.pessoaAlterada.responsavels}"
							var="resp">

							<p:column>
								<f:facet name="header">
									<h:outputText value="#{msgs.responsavel}" />
								</f:facet>
								<h:outputText
									value="#{resp.pessoaFisica.nome}" />
							</p:column>
							
							<p:column>
								<f:facet name="header">
									<h:outputText value="#{msgs.form_tipo}" />
								</f:facet>
								<h:outputText value="#{resp.tipo.descricao}" />
							</p:column>
							<p:column>
								<f:facet name="header">
									<h:outputText value="#{msgs.coluna_data_inicio}" />
								</f:facet>
								<h:outputText value="#{resp.dataInicioExercicio}">
									<f:convertDateTime pattern="dd/MM/yyyy" />
								</h:outputText>
							</p:column>
							<p:column>
								<f:facet name="header">
									<h:outputText value="#{msgs.coluna_data_fim_exercicio}" />
								</f:facet>
								<h:outputText value="#{resp.dataFimExercicio}">
									<f:convertDateTime pattern="dd/MM/yyyy" />
								</h:outputText>
							</p:column>
						</p:dataTable>
					</p:panel>


					<p:commandButton value="#{msgs.btn_finalizar}" update="pessoaForm"
						actionListener="#{solicitacaoMB.finalizar}"
						process="panel1 panel2" action="solicitacao_detalhe.jsf"
						ajax="false" />
				</h:form>

				<div class="content-separator"></div>



				<div class="clearer"></div>

			</div>


		</div>


	</ui:define>

</ui:composition>